package com.yantu.controller.student;

import com.yantu.bean.UserEventLog;
import com.yantu.mapper.UserEventLogMapper;
import com.yantu.util.Result;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@RestController
@ApiModel("用户动态接口")
public class StudentUserLogController {
    @Autowired
    UserEventLogMapper userEventLogMapper;

    @GetMapping("/UserLog/")
    @ApiOperation("用户动态")
    public Result UserLog()  {

        List<Object> list = new ArrayList();
        List<UserEventLog> userEventLogs = userEventLogMapper.selectList(null);
        if (userEventLogs!=null){
            for (UserEventLog userEventLog : userEventLogs) {
                HashMap<String, Object> map = new HashMap<>();
                map.put("id",userEventLog.getId());
                map.put("userId",userEventLog.getUserId());
                map.put("userName",userEventLog.getUserName());
                map.put("realName",userEventLog.getRealName());
                map.put("content",userEventLog.getContent());
                map.put("createTime",userEventLog.getCreateTime());
                list.add(map);
            }
            return Result.succ(200, "查询不到数据", list);
        }


         return Result.succ(200, "查询不到数据", null);


    }

}
